
require "girl/init"

local graph = nil;
local gui = nil;
local wnd = nil;
local gm = nil;
local ps = nil;
local psclick = false;
local show_info = false;
local title = "";

local psconf = {};
local pi = 3.1415926;

function ps_script(export)
	local script = "";
	
	script = script.."-- Out Directory : "..love.filesystem.getWorkingDirectory()..((export and "\13\10") or "\n");
	script = script.."ps:setBufferSize("..psconf.buffer_size..");"..((export and "\13\10") or "\n");
	script = script.."ps:setColors("..psconf.colors[1]..","
		..psconf.colors[2]..","..psconf.colors[3]..","..psconf.colors[4]..","
		..psconf.colors[5]..","..psconf.colors[6]..","..psconf.colors[7]..","
		..psconf.colors[8]..");"..((export and "\13\10") or "\n");
	script = script.."ps:setDirection("..psconf.direction..");"..((export and "\13\10") or "\n");
	script = script.."ps:setEmissionRate("..psconf.emission_rate..");"..((export and "\13\10") or "\n");
	script = script.."ps:setGravity("..psconf.gravity[1]..","..psconf.gravity[2]..");"..((export and "\13\10") or "\n");
	script = script.."ps:setLifetime("..psconf.lifetime..");"..((export and "\13\10") or "\n");
	script = script.."ps:setParticleLife("..psconf.particle_life[1]..","..psconf.particle_life[2]..");"..((export and "\13\10") or "\n");
	script = script.."ps:setRadialAcceleration("..psconf.radial_acceleration[1]..","..psconf.radial_acceleration[2]..");"..((export and "\13\10") or "\n");
	script = script.."ps:setRotation("..psconf.rotation[1]..","..psconf.rotation[2]..");"..((export and "\13\10") or "\n");
	script = script.."ps:setSizes("..psconf.sizes[1]..","..psconf.sizes[2]..",1);\n";
	script = script.."ps:setSpeed("..psconf.speed[1]..","..psconf.speed[2]..");"..((export and "\13\10") or "\n");
	script = script.."ps:setSpin("..psconf.spin[1]..","..psconf.spin[2]..");"..((export and "\13\10") or "\n");
	script = script.."ps:setSpread("..psconf.spread..");"..((export and "\13\10") or "\n");
	script = script.."ps:setTangentialAcceleration("..psconf.tangential_acceleration[1]..","..psconf.tangential_acceleration[2]..");"..((export and "\13\10") or "\n");
	script = script.."-----------------------"..((export and "\13\10") or "\n").."--current particles ["..ps:count().."]"..((export and "\13\10") or "\n");
	
	return script;
end

function ps_init()
	local ww, wh = g._getWidth(), g._getHeight();

	g:createImageFromPath("ps1","psimg/ps1.png");
	g:createImageFromPath("ps2","psimg/ps2.png");
	g:createImageFromPath("ps3","psimg/ps3.png");
	g:createParticleSystem("ps", "ps1", 100);
	ps = g:getParticleSystem("ps");
	ps:setPosition((ww-192)/2+192,wh/2);
	ps:start();
end

function gui_init()
	local ww, wh = g._getWidth(), g._getHeight();
	local cw, ch = 192, wh;
	local iw, ih = 0, 0;
	
	g:createCanvas("gui_canvas", cw, ch);
	iw, ih = g:getImageSize("normal");
	
	gui = Girl.Gui(0, 0, cw, ch, g, "gui_canvas");
	gui:open(gui.AnimaEffect.fade, 50);
	
	-- 背景
	local background = Girl.View.Picture(cw, ch);
	background:setImage("normal");
	background:setImageColor({100,190,255,230});
	background:setMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
	gui:add("bg", background, 0, 0);
	
	-- setBufferSize 滑动条
	local init_BufferSize = function ()
		local slider_buffer_size = Girl.View.Slider(150, 10);
		slider_buffer_size:setValue(.05);
		slider_buffer_size:setBackground("click");
		slider_buffer_size:setBackgroundColor({100,200,255,200});
		slider_buffer_size:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_buffer_size:setSliderRect(2, 2, 146, 6);
		slider_buffer_size:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_buffer_size, 10, 10);
		
		local slider_buffer_text = Girl.View.Label(60,12);
		slider_buffer_text:setFont("font8");
		slider_buffer_text:setLabel("Buffer Size :");
		background:add(nil, slider_buffer_text, 2, 2);
		
		local slider_buffer_value = Girl.View.Label(30, 12);
		slider_buffer_value:setFont("font8");
		slider_buffer_value:setAlign(slider_buffer_value.AlignEnum.right);
		background:add(nil, slider_buffer_value, 155, 11);
		
		-- setBufferSize
		slider_buffer_size.onValueChange = function (this)
			local v = math.ceil(slider_buffer_size:getValue()*5000);
			slider_buffer_value:setLabel(v);
			psconf.buffer_size = v;
			ps:setBufferSize(v);
		end
		slider_buffer_size:onValueChange();
	end
	init_BufferSize();
	
	-- setColors 滑动条
	local init_Color = function ()
		-- r
		local slider_color1_r = Girl.View.Slider(150, 10);
		slider_color1_r:setValue(1.0);
		slider_color1_r:setBackground("click");
		slider_color1_r:setBackgroundColor({100,200,255,200});
		slider_color1_r:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_color1_r:setSliderRect(2, 2, 146, 6);
		slider_color1_r:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_color1_r, 10, 30);
		
		local slider_color1_rvalue = Girl.View.Label(30, 12);
		slider_color1_rvalue:setFont("font8");
		slider_color1_rvalue:setAlign(slider_color1_rvalue.AlignEnum.right);
		background:add(nil, slider_color1_rvalue, 155, 31);
		
		-- g
		local slider_color1_g = Girl.View.Slider(150, 10);
		slider_color1_g:setValue(1.0);
		slider_color1_g:setBackground("click");
		slider_color1_g:setBackgroundColor({100,200,255,200});
		slider_color1_g:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_color1_g:setSliderRect(2, 2, 146, 6);
		slider_color1_g:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_color1_g, 10, 40);
		
		local slider_color1_gvalue = Girl.View.Label(30, 12);
		slider_color1_gvalue:setFont("font8");
		slider_color1_gvalue:setAlign(slider_color1_gvalue.AlignEnum.right);
		background:add(nil, slider_color1_gvalue, 155, 41);
		
		-- b
		local slider_color1_b = Girl.View.Slider(150, 10);
		slider_color1_b:setValue(1.0);
		slider_color1_b:setBackground("click");
		slider_color1_b:setBackgroundColor({100,200,255,200});
		slider_color1_b:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_color1_b:setSliderRect(2, 2, 146, 6);
		slider_color1_b:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_color1_b, 10, 50);
		
		local slider_color1_bvalue = Girl.View.Label(30, 12);
		slider_color1_bvalue:setFont("font8");
		slider_color1_bvalue:setAlign(slider_color1_bvalue.AlignEnum.right);
		background:add(nil, slider_color1_bvalue, 155, 51);
		
		-- a
		local slider_color1_a = Girl.View.Slider(150, 10);
		slider_color1_a:setValue(1.0);
		slider_color1_a:setBackground("click");
		slider_color1_a:setBackgroundColor({100,200,255,200});
		slider_color1_a:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_color1_a:setSliderRect(2, 2, 146, 6);
		slider_color1_a:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_color1_a, 10, 60);
		
		local slider_color1_avalue = Girl.View.Label(30, 12);
		slider_color1_avalue:setFont("font8");
		slider_color1_avalue:setAlign(slider_color1_avalue.AlignEnum.right);
		background:add(nil, slider_color1_avalue, 155, 61);
		
		-- r
		local slider_color2_r = Girl.View.Slider(150, 10);
		slider_color2_r:setValue(.5);
		slider_color2_r:setBackground("click");
		slider_color2_r:setBackgroundColor({100,200,255,200});
		slider_color2_r:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_color2_r:setSliderRect(2, 2, 146, 6);
		slider_color2_r:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_color2_r, 10, 80);
		
		local slider_color2_rvalue = Girl.View.Label(30, 12);
		slider_color2_rvalue:setFont("font8");
		slider_color2_rvalue:setAlign(slider_color2_rvalue.AlignEnum.right);
		background:add(nil, slider_color2_rvalue, 155, 81);
		
		-- g
		local slider_color2_g = Girl.View.Slider(150, 10);
		slider_color2_g:setValue(.5);
		slider_color2_g:setBackground("click");
		slider_color2_g:setBackgroundColor({100,200,255,200});
		slider_color2_g:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_color2_g:setSliderRect(2, 2, 146, 6);
		slider_color2_g:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_color2_g, 10, 90);
		
		local slider_color2_gvalue = Girl.View.Label(30, 12);
		slider_color2_gvalue:setFont("font8");
		slider_color2_gvalue:setAlign(slider_color2_gvalue.AlignEnum.right);
		background:add(nil, slider_color2_gvalue, 155, 91);
		
		-- b
		local slider_color2_b = Girl.View.Slider(150, 10);
		slider_color2_b:setValue(.5);
		slider_color2_b:setBackground("click");
		slider_color2_b:setBackgroundColor({100,200,255,200});
		slider_color2_b:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_color2_b:setSliderRect(2, 2, 146, 6);
		slider_color2_b:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_color2_b, 10, 100);
		
		local slider_color2_bvalue = Girl.View.Label(30, 12);
		slider_color2_bvalue:setFont("font8");
		slider_color2_bvalue:setAlign(slider_color2_bvalue.AlignEnum.right);
		background:add(nil, slider_color2_bvalue, 155, 101);
		
		-- a
		local slider_color2_a = Girl.View.Slider(150, 10);
		slider_color2_a:setValue(1.0);
		slider_color2_a:setBackground("click");
		slider_color2_a:setBackgroundColor({100,200,255,200});
		slider_color2_a:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_color2_a:setSliderRect(2, 2, 146, 6);
		slider_color2_a:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_color2_a, 10, 110);
		
		local slider_color2_avalue = Girl.View.Label(30, 12);
		slider_color2_avalue:setFont("font8");
		slider_color2_avalue:setAlign(slider_color2_avalue.AlignEnum.right);
		background:add(nil, slider_color2_avalue, 155, 111);
		
		local slider_color1_text = Girl.View.Label(60,12);
		slider_color1_text:setFont("font8");
		slider_color1_text:setLabel("Color 1 :");
		background:add(nil, slider_color1_text, 2, 22);
		
		local slider_color2_text = Girl.View.Label(60,12);
		slider_color2_text:setFont("font8");
		slider_color2_text:setLabel("Color 2 :");
		background:add(nil, slider_color2_text, 2, 72);
		
		-- r
		slider_color1_r.onValueChange = function (this)
			local r, g, b, a = math.ceil(slider_color1_r:getValue()*255),
				math.ceil(slider_color1_g:getValue()*255),
				math.ceil(slider_color1_b:getValue()*255),
				math.ceil(slider_color1_a:getValue()*255);
			local r2, g2, b2, a2 = math.ceil(slider_color2_r:getValue()*255),
				math.ceil(slider_color2_g:getValue()*255),
				math.ceil(slider_color2_b:getValue()*255),
				math.ceil(slider_color2_a:getValue()*255);
			slider_color1_r:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
			slider_color1_g:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
			slider_color1_b:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
			slider_color1_a:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
		
			slider_color1_rvalue:setLabel(r);
			ps:setColors(r, g, b, a, r2, g2, b2, a2);
			psconf.colors = {r, g, b, a, r2, g2, b2, a2};
		end
		slider_color1_r:onValueChange();
		-- g
		slider_color1_g.onValueChange = function (this)
			local r, g, b, a = math.ceil(slider_color1_r:getValue()*255),
				math.ceil(slider_color1_g:getValue()*255),
				math.ceil(slider_color1_b:getValue()*255),
				math.ceil(slider_color1_a:getValue()*255);
			local r2, g2, b2, a2 = math.ceil(slider_color2_r:getValue()*255),
				math.ceil(slider_color2_g:getValue()*255),
				math.ceil(slider_color2_b:getValue()*255),
				math.ceil(slider_color2_a:getValue()*255);
			slider_color1_r:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
			slider_color1_g:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
			slider_color1_b:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
			slider_color1_a:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
		
			slider_color1_gvalue:setLabel(g);
			ps:setColors(r, g, b, a, r2, g2, b2, a2);
			psconf.colors = {r, g, b, a, r2, g2, b2, a2};
		end
		slider_color1_g:onValueChange();
		-- b
		slider_color1_b.onValueChange = function (this)
			local r, g, b, a = math.ceil(slider_color1_r:getValue()*255),
				math.ceil(slider_color1_g:getValue()*255),
				math.ceil(slider_color1_b:getValue()*255),
				math.ceil(slider_color1_a:getValue()*255);
			local r2, g2, b2, a2 = math.ceil(slider_color2_r:getValue()*255),
				math.ceil(slider_color2_g:getValue()*255),
				math.ceil(slider_color2_b:getValue()*255),
				math.ceil(slider_color2_a:getValue()*255);
			slider_color1_r:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
			slider_color1_g:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
			slider_color1_b:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
			slider_color1_a:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
		
			slider_color1_bvalue:setLabel(b);
			ps:setColors(r, g, b, a, r2, g2, b2, a2);
			psconf.colors = {r, g, b, a, r2, g2, b2, a2};
		end
		slider_color1_b:onValueChange();
		-- a
		slider_color1_a.onValueChange = function (this)
			local r, g, b, a = math.ceil(slider_color1_r:getValue()*255),
				math.ceil(slider_color1_g:getValue()*255),
				math.ceil(slider_color1_b:getValue()*255),
				math.ceil(slider_color1_a:getValue()*255);
			local r2, g2, b2, a2 = math.ceil(slider_color2_r:getValue()*255),
				math.ceil(slider_color2_g:getValue()*255),
				math.ceil(slider_color2_b:getValue()*255),
				math.ceil(slider_color2_a:getValue()*255);
		
			slider_color1_avalue:setLabel(a);
			ps:setColors(r, g, b, a, r2, g2, b2, a2);
			psconf.colors = {r, g, b, a, r2, g2, b2, a2};
		end
		slider_color1_a:onValueChange();
		
		-- r
		slider_color2_r.onValueChange = function (this)
			local r, g, b, a = math.ceil(slider_color2_r:getValue()*255),
				math.ceil(slider_color2_g:getValue()*255),
				math.ceil(slider_color2_b:getValue()*255),
				math.ceil(slider_color2_a:getValue()*255);
			local r1, g1, b1, a1 = math.ceil(slider_color1_r:getValue()*255),
				math.ceil(slider_color1_g:getValue()*255),
				math.ceil(slider_color1_b:getValue()*255),
				math.ceil(slider_color1_a:getValue()*255);
			slider_color2_r:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
			slider_color2_g:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
			slider_color2_b:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
			slider_color2_a:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
		
			slider_color2_rvalue:setLabel(r);
			ps:setColors(r1, g1, b1, a1, r, g, b, a);
			psconf.colors = {r1, g1, b1, a1, r, g, b, a};
		end
		slider_color2_r:onValueChange();
		-- g
		slider_color2_g.onValueChange = function (this)
			local r, g, b, a = math.ceil(slider_color2_r:getValue()*255),
				math.ceil(slider_color2_g:getValue()*255),
				math.ceil(slider_color2_b:getValue()*255),
				math.ceil(slider_color2_a:getValue()*255);
			local r1, g1, b1, a1 = math.ceil(slider_color1_r:getValue()*255),
				math.ceil(slider_color1_g:getValue()*255),
				math.ceil(slider_color1_b:getValue()*255),
				math.ceil(slider_color1_a:getValue()*255);
			slider_color2_r:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
			slider_color2_g:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
			slider_color2_b:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
			slider_color2_a:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
		
			slider_color2_gvalue:setLabel(g);
			ps:setColors(r1, g1, b1, a1, r, g, b, a);
			psconf.colors = {r1, g1, b1, a1, r, g, b, a};
		end
		slider_color2_g:onValueChange();
		-- b
		slider_color2_b.onValueChange = function (this)
			local r, g, b, a = math.ceil(slider_color2_r:getValue()*255),
				math.ceil(slider_color2_g:getValue()*255),
				math.ceil(slider_color2_b:getValue()*255),
				math.ceil(slider_color2_a:getValue()*255);
			local r1, g1, b1, a1 = math.ceil(slider_color1_r:getValue()*255),
				math.ceil(slider_color1_g:getValue()*255),
				math.ceil(slider_color1_b:getValue()*255),
				math.ceil(slider_color1_a:getValue()*255);
			slider_color2_r:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
			slider_color2_g:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
			slider_color2_b:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
			slider_color2_a:setSliderColor({r,g,b,200}, {r,g,b,200}, {r,g,b,255});
		
			slider_color2_bvalue:setLabel(b);
			ps:setColors(r1, g1, b1, a1, r, g, b, a);
			psconf.colors = {r1, g1, b1, a1, r, g, b, a};
		end
		slider_color2_b:onValueChange();
		-- a
		slider_color2_a.onValueChange = function (this)
			local r, g, b, a = math.ceil(slider_color2_r:getValue()*255),
				math.ceil(slider_color2_g:getValue()*255),
				math.ceil(slider_color2_b:getValue()*255),
				math.ceil(slider_color2_a:getValue()*255);
			local r1, g1, b1, a1 = math.ceil(slider_color1_r:getValue()*255),
				math.ceil(slider_color1_g:getValue()*255),
				math.ceil(slider_color1_b:getValue()*255),
				math.ceil(slider_color1_a:getValue()*255);
		
			slider_color2_avalue:setLabel(a);
			ps:setColors(r1, g1, b1, a1, r, g, b, a);
			psconf.colors = {r1, g1, b1, a1, r, g, b, a};
		end
		slider_color2_a:onValueChange();
	end
	init_Color();
	
	-- setDirection 滑动条
	local init_Direction = function ()
		local slider_direction = Girl.View.Slider(150, 10);
		slider_direction:setValue(1.0);
		slider_direction:setBackground("click");
		slider_direction:setBackgroundColor({100,200,255,200});
		slider_direction:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_direction:setSliderRect(2, 2, 146, 6);
		slider_direction:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_direction, 10, 130);
		
		local slider_direction_text = Girl.View.Label(60,12);
		slider_direction_text:setFont("font8");
		slider_direction_text:setLabel("Direction :");
		background:add(nil, slider_direction_text, 2, 122);
		
		local slider_direction_value = Girl.View.Label(30, 12);
		slider_direction_value:setFont("font8");
		slider_direction_value:setAlign(slider_direction_value.AlignEnum.right);
		background:add(nil, slider_direction_value, 155, 131);
		
		-- setDirection
		slider_direction.onValueChange = function (this)
			local v = math.ceil(slider_direction:getValue()*360);
			slider_direction_value:setLabel(v);
			psconf.direction = v/360*pi*2;
			ps:setDirection(v/360*pi*2);
		end
		slider_direction:onValueChange();
	end
	init_Direction();
	
	-- setEmissionRate 滑动条
	local init_EmissionRate = function ()
		local slider_emission_rate = Girl.View.Slider(150, 10);
		slider_emission_rate:setValue(.1);
		slider_emission_rate:setBackground("click");
		slider_emission_rate:setBackgroundColor({100,200,255,200});
		slider_emission_rate:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_emission_rate:setSliderRect(2, 2, 146, 6);
		slider_emission_rate:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_emission_rate, 10, 150);
		
		local slider_emission_rate_text = Girl.View.Label(70,12);
		slider_emission_rate_text:setFont("font8");
		slider_emission_rate_text:setLabel("Emission Rate :");
		background:add(nil, slider_emission_rate_text, 2, 142);
		
		local slider_emission_rate_value = Girl.View.Label(30, 12);
		slider_emission_rate_value:setFont("font8");
		slider_emission_rate_value:setAlign(slider_emission_rate_value.AlignEnum.right);
		background:add(nil, slider_emission_rate_value, 155, 151);
		
		-- setEmissionRate
		slider_emission_rate.onValueChange = function (this)
			local v = math.ceil(slider_emission_rate:getValue()*2000);
			slider_emission_rate_value:setLabel(v);
			psconf.emission_rate = v;
			ps:setEmissionRate(v);		
		end
		slider_emission_rate:onValueChange();
	end
	init_EmissionRate();
	
	-- setGravity 滑动条
	local init_Gravity = function ()
		-- min
		local slider_gravity_min = Girl.View.Slider(150, 10);
		slider_gravity_min:setValue(.1);
		slider_gravity_min:setBackground("click");
		slider_gravity_min:setBackgroundColor({100,200,255,200});
		slider_gravity_min:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_gravity_min:setSliderRect(2, 2, 146, 6);
		slider_gravity_min:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_gravity_min, 10, 170);
		
		local slider_gravity_min_value = Girl.View.Label(30, 12);
		slider_gravity_min_value:setFont("font8");
		slider_gravity_min_value:setAlign(slider_gravity_min_value.AlignEnum.right);
		background:add(nil, slider_gravity_min_value, 155, 171);
		
		-- max
		local slider_gravity_max = Girl.View.Slider(150, 10);
		slider_gravity_max:setValue(.2);
		slider_gravity_max:setBackground("click");
		slider_gravity_max:setBackgroundColor({100,200,255,200});
		slider_gravity_max:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_gravity_max:setSliderRect(2, 2, 146, 6);
		slider_gravity_max:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_gravity_max, 10, 180);
		
		local slider_gravity_max_value = Girl.View.Label(30, 12);
		slider_gravity_max_value:setFont("font8");
		slider_gravity_max_value:setAlign(slider_gravity_max_value.AlignEnum.right);
		background:add(nil, slider_gravity_max_value, 155, 181);
		
		local slider_gravity_text = Girl.View.Label(90,12);
		slider_gravity_text:setFont("font8");
		slider_gravity_text:setLabel("Gravity(min, max) :");
		background:add(nil, slider_gravity_text, 2, 162);
		
		-- min, max
		slider_gravity_min.onValueChange = function (this)
			local max = math.ceil(slider_gravity_max:getValue()*1000);
			local min = math.ceil(slider_gravity_min:getValue()*1000);
		
			psconf.gravity = {min, max};
			ps:setGravity(min, max);
			if max < min then
				slider_gravity_max:setValue(min/1000);
			end
			slider_gravity_min_value:setLabel(min);
		end
		slider_gravity_min:onValueChange();
		slider_gravity_max.onValueChange = function (this)
			local max = math.ceil(slider_gravity_max:getValue()*1000);
			local min = math.ceil(slider_gravity_min:getValue()*1000);
		
			psconf.gravity = {min, max};
			ps:setGravity(min, max);
			if max < min then
				slider_gravity_min:setValue(max/1000);
			end
			slider_gravity_max_value:setLabel(max);
		end
		slider_gravity_max:onValueChange();
	end
	init_Gravity();
	
	-- setLifetime 滑动条
	local init_Lifetime = function ()
		-- min
		local slider_lifetime = Girl.View.Slider(150, 10);
		slider_lifetime:setValue(.3);
		slider_lifetime:setBackground("click");
		slider_lifetime:setBackgroundColor({100,200,255,200});
		slider_lifetime:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_lifetime:setSliderRect(2, 2, 146, 6);
		slider_lifetime:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_lifetime, 10, 200);
		
		local slider_lifetime_value = Girl.View.Label(30, 12);
		slider_lifetime_value:setFont("font8");
		slider_lifetime_value:setAlign(slider_lifetime_value.AlignEnum.right);
		background:add(nil, slider_lifetime_value, 155, 201);
		
		local slider_lifetime_text = Girl.View.Label(60,12);
		slider_lifetime_text:setFont("font8");
		slider_lifetime_text:setLabel("Lifetime :");
		background:add(nil, slider_lifetime_text, 2, 192);
		
		-- setLifetime
		slider_lifetime.onValueChange = function (this)
			local v = math.ceil(slider_lifetime:getValue()*200);
			if v==0 then
				v=-1;
			end
			slider_lifetime_value:setLabel(v);
			psconf.lifetime = v;
			ps:setLifetime(v);
		end
		slider_lifetime:onValueChange();
	end
	init_Lifetime();
	
	-- setParticleLife 滑动条
	local init_ParticleLife = function ()
		-- min
		local slider_pl_min = Girl.View.Slider(150, 10);
		slider_pl_min:setValue(.1);
		slider_pl_min:setBackground("click");
		slider_pl_min:setBackgroundColor({100,200,255,200});
		slider_pl_min:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_pl_min:setSliderRect(2, 2, 146, 6);
		slider_pl_min:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_pl_min, 10, 220);
		
		local slider_pl_min_value = Girl.View.Label(30, 12);
		slider_pl_min_value:setFont("font8");
		slider_pl_min_value:setAlign(slider_pl_min_value.AlignEnum.right);
		background:add(nil, slider_pl_min_value, 155, 221);
		
		-- max
		local slider_pl_max = Girl.View.Slider(150, 10);
		slider_pl_max:setValue(.2);
		slider_pl_max:setBackground("click");
		slider_pl_max:setBackgroundColor({100,200,255,200});
		slider_pl_max:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_pl_max:setSliderRect(2, 2, 146, 6);
		slider_pl_max:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_pl_max, 10, 230);
		
		local slider_pl_max_value = Girl.View.Label(30, 12);
		slider_pl_max_value:setFont("font8");
		slider_pl_max_value:setAlign(slider_pl_max_value.AlignEnum.right);
		background:add(nil, slider_pl_max_value, 155, 231);
		
		local slider_pl_text = Girl.View.Label(120,12);
		slider_pl_text:setFont("font8");
		slider_pl_text:setLabel("Particle Life(min, max) :");
		background:add(nil, slider_pl_text, 2, 212);
		
		-- min, max
		slider_pl_min.onValueChange = function (this)
			local max = math.ceil(slider_pl_max:getValue()*500)/100;
			local min = math.ceil(slider_pl_min:getValue()*500)/100;
		
			psconf.particle_life = {min, max};
			ps:setParticleLife(min, max);
			if max < min then
				slider_pl_max:setValue(min/5);
			end
			slider_pl_min_value:setLabel(min);
		end
		slider_pl_min:onValueChange();
		slider_pl_max.onValueChange = function (this)
			local max = math.ceil(slider_pl_max:getValue()*500)/100;
			local min = math.ceil(slider_pl_min:getValue()*500)/100;
		
			psconf.particle_life = {min, max};
			ps:setParticleLife(min, max);
			if max < min then
				slider_pl_min:setValue(max/5);
			end
			slider_pl_max_value:setLabel(max);
		end
		slider_pl_max:onValueChange();
	end
	init_ParticleLife();
	
	-- setRadialAcceleration 滑动条
	local init_RadialAcceleration = function ()
		-- min
		local slider_ra_min = Girl.View.Slider(150, 10);
		slider_ra_min:setValue(.5);
		slider_ra_min:setBackground("click");
		slider_ra_min:setBackgroundColor({100,200,255,200});
		slider_ra_min:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_ra_min:setSliderRect(2, 2, 146, 6);
		slider_ra_min:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_ra_min, 10, 250);
		
		local slider_ra_min_value = Girl.View.Label(30, 12);
		slider_ra_min_value:setFont("font8");
		slider_ra_min_value:setAlign(slider_ra_min_value.AlignEnum.right);
		background:add(nil, slider_ra_min_value, 155, 251);
		
		-- max
		local slider_ra_max = Girl.View.Slider(150, 10);
		slider_ra_max:setValue(.5);
		slider_ra_max:setBackground("click");
		slider_ra_max:setBackgroundColor({100,200,255,200});
		slider_ra_max:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_ra_max:setSliderRect(2, 2, 146, 6);
		slider_ra_max:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_ra_max, 10, 260);
		
		local slider_ra_max_value = Girl.View.Label(30, 12);
		slider_ra_max_value:setFont("font8");
		slider_ra_max_value:setAlign(slider_ra_max_value.AlignEnum.right);
		background:add(nil, slider_ra_max_value, 155, 261);
		
		local slider_ra_text = Girl.View.Label(140,12);
		slider_ra_text:setFont("font8");
		slider_ra_text:setLabel("Radial Acceleration(min, max) :");
		background:add(nil, slider_ra_text, 2, 242);
		
		-- min, max
		slider_ra_min.onValueChange = function (this)
			local max = math.ceil(slider_ra_max:getValue()*20000);
			local min = math.ceil(slider_ra_min:getValue()*20000);
		
			ps:setRadialAcceleration(min-10000, max-10000);
			psconf.radial_acceleration = {min-10000, max-10000};
			if max < min then
				slider_ra_max:setValue(min/20000);
			end
			slider_ra_min_value:setLabel(min-10000);
		end
		slider_ra_min:onValueChange();
		slider_ra_max.onValueChange = function (this)
			local max = math.ceil(slider_ra_max:getValue()*20000);
			local min = math.ceil(slider_ra_min:getValue()*20000);
		
			ps:setRadialAcceleration(min-10000, max-10000);
			psconf.radial_acceleration = {min-10000, max-10000};
			if max < min then
				slider_ra_min:setValue(max/20000);
			end
			slider_ra_max_value:setLabel(max-10000);
		end
		slider_ra_max:onValueChange();
	end
	init_RadialAcceleration();
	
	-- setRotation 滑动条
	local init_Rotation = function ()
		-- min
		local slider_rotation_min = Girl.View.Slider(150, 10);
		slider_rotation_min:setValue(.0);
		slider_rotation_min:setBackground("click");
		slider_rotation_min:setBackgroundColor({100,200,255,200});
		slider_rotation_min:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_rotation_min:setSliderRect(2, 2, 146, 6);
		slider_rotation_min:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_rotation_min, 10, 280);
		
		local slider_rotation_min_value = Girl.View.Label(30, 12);
		slider_rotation_min_value:setFont("font8");
		slider_rotation_min_value:setAlign(slider_rotation_min_value.AlignEnum.right);
		background:add(nil, slider_rotation_min_value, 155, 281);
		
		-- max
		local slider_rotation_max = Girl.View.Slider(150, 10);
		slider_rotation_max:setValue(.0);
		slider_rotation_max:setBackground("click");
		slider_rotation_max:setBackgroundColor({100,200,255,200});
		slider_rotation_max:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_rotation_max:setSliderRect(2, 2, 146, 6);
		slider_rotation_max:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_rotation_max, 10, 290);
		
		local slider_rotation_max_value = Girl.View.Label(30, 12);
		slider_rotation_max_value:setFont("font8");
		slider_rotation_max_value:setAlign(slider_rotation_max_value.AlignEnum.right);
		background:add(nil, slider_rotation_max_value, 155, 291);
		
		local slider_rotation_text = Girl.View.Label(120,12);
		slider_rotation_text:setFont("font8");
		slider_rotation_text:setLabel("Rotation(min, max) :");
		background:add(nil, slider_rotation_text, 2, 272);
		
		-- min, max
		slider_rotation_min.onValueChange = function (this)
			local max = math.ceil(slider_rotation_max:getValue()*360);
			local min = math.ceil(slider_rotation_min:getValue()*360);
		
			psconf.rotation = {min/360*pi*2, max/360*pi*2};
			ps:setRotation(min/360*pi*2, max/360*pi*2);
			if max < min then
				slider_rotation_max:setValue(min/360);
			end
			slider_rotation_min_value:setLabel(min);
		end
		slider_rotation_min:onValueChange();
		slider_rotation_max.onValueChange = function (this)
			local max = math.ceil(slider_rotation_max:getValue()*360);
			local min = math.ceil(slider_rotation_min:getValue()*360);
		
			psconf.rotation = {min/360*pi*2, max/360*pi*2};
			ps:setRotation(min/360*pi*2, max/360*pi*2);
			if max < min then
				slider_rotation_min:setValue(max/360);
			end
			slider_rotation_max_value:setLabel(max);
		end
		slider_rotation_max:onValueChange();
	end
	init_Rotation();
	
	-- setSizes 滑动条
	local init_Sizes = function ()
		-- min
		local slider_sizes_min = Girl.View.Slider(150, 10);
		slider_sizes_min:setValue(.2);
		slider_sizes_min:setBackground("click");
		slider_sizes_min:setBackgroundColor({100,200,255,200});
		slider_sizes_min:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_sizes_min:setSliderRect(2, 2, 146, 6);
		slider_sizes_min:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_sizes_min, 10, 310);
		
		local slider_sizes_min_value = Girl.View.Label(30, 12);
		slider_sizes_min_value:setFont("font8");
		slider_sizes_min_value:setAlign(slider_sizes_min_value.AlignEnum.right);
		background:add(nil, slider_sizes_min_value, 155, 311);
		
		-- max
		local slider_sizes_max = Girl.View.Slider(150, 10);
		slider_sizes_max:setValue(.2);
		slider_sizes_max:setBackground("click");
		slider_sizes_max:setBackgroundColor({100,200,255,200});
		slider_sizes_max:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_sizes_max:setSliderRect(2, 2, 146, 6);
		slider_sizes_max:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_sizes_max, 10, 320);
		
		local slider_sizes_max_value = Girl.View.Label(30, 12);
		slider_sizes_max_value:setFont("font8");
		slider_sizes_max_value:setAlign(slider_sizes_max_value.AlignEnum.right);
		background:add(nil, slider_sizes_max_value, 155, 321);
		
		local slider_sizes_text = Girl.View.Label(120,12);
		slider_sizes_text:setFont("font8");
		slider_sizes_text:setLabel("Sizes(min, max) :");
		background:add(nil, slider_sizes_text, 2, 302);
		
		-- min, max
		slider_sizes_min.onValueChange = function (this)
			local max = math.ceil(slider_sizes_max:getValue()*500)/100;
			local min = math.ceil(slider_sizes_min:getValue()*500)/100;
		
			ps:setSizes(min, max, 1);
			psconf.sizes = {min, max};
			if max < min then
				slider_sizes_max:setValue(min/5);
			end
			slider_sizes_min_value:setLabel(min);
		end
		slider_sizes_min:onValueChange();
		slider_sizes_max.onValueChange = function (this)
			local max = math.ceil(slider_sizes_max:getValue()*500)/100;
			local min = math.ceil(slider_sizes_min:getValue()*500)/100;
		
			ps:setSizes(min, max, 1);
			psconf.sizes = {min, max};
			if max < min then
				slider_sizes_min:setValue(max/5);
			end
			slider_sizes_max_value:setLabel(max);
		end
		slider_sizes_max:onValueChange();
	end
	init_Sizes();
	
	-- setSpeed 滑动条
	local init_Speed = function ()
		-- min
		local slider_speed_min = Girl.View.Slider(150, 10);
		slider_speed_min:setValue(.1);
		slider_speed_min:setBackground("click");
		slider_speed_min:setBackgroundColor({100,200,255,200});
		slider_speed_min:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_speed_min:setSliderRect(2, 2, 146, 6);
		slider_speed_min:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_speed_min, 10, 340);
		
		local slider_speed_min_value = Girl.View.Label(30, 12);
		slider_speed_min_value:setFont("font8");
		slider_speed_min_value:setAlign(slider_speed_min_value.AlignEnum.right);
		background:add(nil, slider_speed_min_value, 155, 341);
		
		-- max
		local slider_speed_max = Girl.View.Slider(150, 10);
		slider_speed_max:setValue(.2);
		slider_speed_max:setBackground("click");
		slider_speed_max:setBackgroundColor({100,200,255,200});
		slider_speed_max:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_speed_max:setSliderRect(2, 2, 146, 6);
		slider_speed_max:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_speed_max, 10, 350);
		
		local slider_speed_max_value = Girl.View.Label(30, 12);
		slider_speed_max_value:setFont("font8");
		slider_speed_max_value:setAlign(slider_speed_max_value.AlignEnum.right);
		background:add(nil, slider_speed_max_value, 155, 351);
		
		local slider_speed_text = Girl.View.Label(90,12);
		slider_speed_text:setFont("font8");
		slider_speed_text:setLabel("Speed(min, max) :");
		background:add(nil, slider_speed_text, 2, 332);
		
		-- min, max
		slider_speed_min.onValueChange = function (this)
			local max = math.ceil(slider_speed_max:getValue()*1000);
			local min = math.ceil(slider_speed_min:getValue()*1000);
		
			ps:setSpeed(min, max);
			psconf.speed = {min, max};
			if max < min then
				slider_speed_max:setValue(min/1000);
			end
			slider_speed_min_value:setLabel(min);
		end
		slider_speed_min:onValueChange();
		slider_speed_max.onValueChange = function (this)
			local max = math.ceil(slider_speed_max:getValue()*1000);
			local min = math.ceil(slider_speed_min:getValue()*1000);
		
			ps:setSpeed(min, max);
			psconf.speed = {min, max};
			if max < min then
				slider_speed_min:setValue(max/1000);
			end
			slider_speed_max_value:setLabel(max);
		end
		slider_speed_max:onValueChange();
	end
	init_Speed();
	
	-- setSpin 滑动条
	local init_Spin = function ()
		-- min
		local slider_spin_min = Girl.View.Slider(150, 10);
		slider_spin_min:setValue(.1);
		slider_spin_min:setBackground("click");
		slider_spin_min:setBackgroundColor({100,200,255,200});
		slider_spin_min:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_spin_min:setSliderRect(2, 2, 146, 6);
		slider_spin_min:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_spin_min, 10, 370);
		
		local slider_spin_min_value = Girl.View.Label(30, 12);
		slider_spin_min_value:setFont("font8");
		slider_spin_min_value:setAlign(slider_spin_min_value.AlignEnum.right);
		background:add(nil, slider_spin_min_value, 155, 371);
		
		-- max
		local slider_spin_max = Girl.View.Slider(150, 10);
		slider_spin_max:setValue(.2);
		slider_spin_max:setBackground("click");
		slider_spin_max:setBackgroundColor({100,200,255,200});
		slider_spin_max:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_spin_max:setSliderRect(2, 2, 146, 6);
		slider_spin_max:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_spin_max, 10, 380);
		
		local slider_spin_max_value = Girl.View.Label(30, 12);
		slider_spin_max_value:setFont("font8");
		slider_spin_max_value:setAlign(slider_spin_max_value.AlignEnum.right);
		background:add(nil, slider_spin_max_value, 155, 381);
		
		local slider_spin_text = Girl.View.Label(90,12);
		slider_spin_text:setFont("font8");
		slider_spin_text:setLabel("Spin(min, max) :");
		background:add(nil, slider_spin_text, 2, 362);
		
		-- min, max
		slider_spin_min.onValueChange = function (this)
			local max = math.ceil(slider_spin_max:getValue()*2000);
			local min = math.ceil(slider_spin_min:getValue()*2000);
		
			ps:setSpin(min, max, 1);
			psconf.spin = {min, max};
			if max < min then
				slider_spin_max:setValue(min/2000);
			end
			slider_spin_min_value:setLabel(min);
		end
		slider_spin_min:onValueChange();
		slider_spin_max.onValueChange = function (this)
			local max = math.ceil(slider_spin_max:getValue()*2000);
			local min = math.ceil(slider_spin_min:getValue()*2000);
		
			ps:setSpin(min, max, 1);
			psconf.spin = {min, max};
			if max < min then
				slider_spin_min:setValue(max/2000);
			end
			slider_spin_max_value:setLabel(max);
		end
		slider_spin_max:onValueChange();
	end
	init_Spin();
	
	-- setSpread 滑动条
	local init_Spread = function ()
		local slider_spread = Girl.View.Slider(150, 10);
		slider_spread:setValue(1.0);
		slider_spread:setBackground("click");
		slider_spread:setBackgroundColor({100,200,255,200});
		slider_spread:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_spread:setSliderRect(2, 2, 146, 6);
		slider_spread:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_spread, 10, 400);
		
		local slider_spread_value = Girl.View.Label(30, 12);
		slider_spread_value:setFont("font8");
		slider_spread_value:setAlign(slider_spread_value.AlignEnum.right);
		background:add(nil, slider_spread_value, 155, 401);
		
		local slider_spread_text = Girl.View.Label(60,12);
		slider_spread_text:setFont("font8");
		slider_spread_text:setLabel("Spread :");
		background:add(nil, slider_spread_text, 2, 392);
		
		-- setSpread
		slider_spread.onValueChange = function (this)
			local v = math.ceil(slider_spread:getValue()*360);
			slider_spread_value:setLabel(v);
			ps:setSpread(v/360*pi*2);
			psconf.spread = v/360*pi*2;
		end
		slider_spread:onValueChange();
	end
	init_Spread();
	
	-- setTangentialAcceleration 滑动条
	local init_TangentialAcceleration = function ()
		-- min
		local slider_ta_min = Girl.View.Slider(150, 10);
		slider_ta_min:setValue(.5);
		slider_ta_min:setBackground("click");
		slider_ta_min:setBackgroundColor({100,200,255,200});
		slider_ta_min:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_ta_min:setSliderRect(2, 2, 146, 6);
		slider_ta_min:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_ta_min, 10, 420);
		
		local slider_ta_min_value = Girl.View.Label(30, 12);
		slider_ta_min_value:setFont("font8");
		slider_ta_min_value:setAlign(slider_ta_min_value.AlignEnum.right);
		background:add(nil, slider_ta_min_value, 155, 421);
		
		-- max
		local slider_ta_max = Girl.View.Slider(150, 10);
		slider_ta_max:setValue(.5);
		slider_ta_max:setBackground("click");
		slider_ta_max:setBackgroundColor({100,200,255,200});
		slider_ta_max:setBackgroundMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		slider_ta_max:setSliderRect(2, 2, 146, 6);
		slider_ta_max:setSliderColor({255,180,150,200}, {255,180,150,200}, {255,180,150,255});
		background:add(nil, slider_ta_max, 10, 430);
		
		local slider_ta_max_value = Girl.View.Label(30, 12);
		slider_ta_max_value:setFont("font8");
		slider_ta_max_value:setAlign(slider_ta_max_value.AlignEnum.right);
		background:add(nil, slider_ta_max_value, 155, 431);
		
		local slider_ta_text = Girl.View.Label(200,12);
		slider_ta_text:setFont("font8");
		slider_ta_text:setLabel("Tangential Acceleration(min, max) :");
		background:add(nil, slider_ta_text, 2, 412);
		
		-- min, max
		slider_ta_min.onValueChange = function (this)
			local max = math.ceil(slider_ta_max:getValue()*5000);
			local min = math.ceil(slider_ta_min:getValue()*5000);
		
			psconf.tangential_acceleration = {min-2500, max-2500};
			ps:setTangentialAcceleration(min-2500, max-2500);
			if max < min then
				slider_ta_max:setValue(min/5000);
			end
			slider_ta_min_value:setLabel(min-2500);
			
		end
		slider_ta_min:onValueChange();
		slider_ta_max.onValueChange = function (this)
			local max = math.ceil(slider_ta_max:getValue()*5000);
			local min = math.ceil(slider_ta_min:getValue()*5000);
		
			psconf.tangential_acceleration = {min-2500, max-2500};
			ps:setTangentialAcceleration(min-2500, max-2500);
			if max < min then
				slider_ta_min:setValue(max/5000);
			end
			slider_ta_max_value:setLabel(max-2500);
		end
		slider_ta_max:onValueChange();
	end
	init_TangentialAcceleration();
	
	local init_Button = function ()
		local psimg = Girl.View.Picture(20,20);
		psimg:setImage("ps1");
		background:add(nil, psimg, 150, 455);
		
		local function bc(this)
			ps:setSprite(g:getImage("ps"..this.label));
			psimg:setImage("ps"..this.label);
		end
	
		local b1 = Girl.View.Button(15, 15);
		b1:setFont("font8");
		b1:setImage("normal", "normal", "click");
		b1:setLabel("1", 4, 3);
		b1:setImageColor({100,200,255,200},{150,250,255,200},{150,250,255,200});
		b1:setMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		b1.onButtonClick = bc;
		background:add(nil, b1, 10, 455);
		
		local b2 = Girl.View.Button(15, 15);
		b2:setFont("font8");
		b2:setImage("normal", "normal", "click");
		b2:setLabel("2", 4, 3);
		b2:setImageColor({100,200,255,200},{150,250,255,200},{150,250,255,200});
		b2:setMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		b2.onButtonClick = bc;
		background:add(nil, b2, 30, 455);
		
		local b3 = Girl.View.Button(15, 15);
		b3:setFont("font8");
		b3:setImage("normal", "normal", "click");
		b3:setLabel("3", 4, 3);
		b3:setImageColor({100,200,255,200},{150,250,255,200},{150,250,255,200});
		b3:setMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		b3.onButtonClick = bc;
		background:add(nil, b3, 50, 455);
		
		local b_sprite_text = Girl.View.Label(200,12);
		b_sprite_text:setFont("font8");
		b_sprite_text:setLabel("Particle System Image :");
		background:add(nil, b_sprite_text, 2, 442);
		
		local showinfobtn = Girl.View.Button(55, 15);
		showinfobtn:setFont("font8");
		showinfobtn:setImage("normal", "normal", "click");
		showinfobtn:setLabel("Show Info", 6, 3);
		showinfobtn:setImageColor({100,200,255,200},{150,250,255,200},{150,250,255,200});
		showinfobtn:setMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		showinfobtn.onButtonClick = function (this) 
			show_info = not show_info;
		end
		background:add(nil, showinfobtn, 10, 475);
		
		local exportbtn = Girl.View.Button(55, 15);
		exportbtn:setFont("font8");
		exportbtn:setImage("normal", "normal", "click");
		exportbtn:setLabel("Export", 6, 3);
		exportbtn:setImageColor({100,200,255,200},{150,250,255,200},{150,250,255,200});
		exportbtn:setMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
		background:add(nil, exportbtn, 10, 495);
		exportbtn.onButtonClick = function (this)
			if wnd:showState() then
				wnd:close(2, exportbtn.rect, true);
			else
				wnd:open(2, exportbtn.rect, true);
			end
		end
		
		local author_info = Girl.View.Label(0,0);
		author_info:setFont("font8");
		author_info:setLabelColor({255,255,255});
		author_info:setLabel("Particle System Tool 0.11\n    write by xeryshrry");
		background:add(nil, author_info, 36, 545);
		author_info:autoResize();
	end
	init_Button();
	
	gm:add("gui", gui);
end

function wnd_init()
	local ww, wh = g._getWidth(), g._getHeight();
	local cw, ch = 200, 60;
	g:createCanvas("wnd_canvas", cw, ch);
	iw, ih = g:getImageSize("normal");
	
	wnd = Girl.Gui((ww-cw)/2, (wh-ch)/2, cw, ch, g, "wnd_canvas");
	
	-- 背景
	local background = Girl.View.Picture(cw, ch);
	background:setImage("normal");
	background:setImageColor({100,190,255,230});
	background:setMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
	background:enableCaption();
	wnd:add("bg", background, 0, 0);
	
	local caption = Girl.View.Label(150,12);
	caption:setFont("font10");
	caption:setLabelColor({255,255,255});
	caption:setLabel("Particle System Script Export");
	caption.parent_mouse_event = true;
	background:add(nil, caption, 2, 2);
	
	local editbox = Girl.View.EditBox(cw-20, 15);
	editbox:setFont("font10");
	editbox:setBorder("click");
	editbox:setMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
	background:add(nil, editbox, 10, 20);
	
	local exportbtn = Girl.View.Button(55, 15);
	exportbtn:setFont("font10");
	exportbtn:setImage("normal", "normal", "click");
	exportbtn:setLabel("Export", 8, 1);
	exportbtn:setImageColor({100,200,255,200},{150,250,255,200},{150,250,255,200});
	exportbtn:setMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
	exportbtn.onButtonClick = function (this)
		local fn = editbox:getText();
		if fn=="" then
			return;
		end
		local luafile = io.open(fn,"wb");
		if luafile==nil then
			return;
		end
		
		luafile:write(ps_script(true));
		luafile:close();
		
		wnd:close(2, {x=10, y=495, width = 55, height = 15}, true);
	end
	background:add(nil, exportbtn, 30, 40);
	
	local closebtn = Girl.View.Button(55, 15);
	closebtn:setFont("font10");
	closebtn:setImage("normal", "normal", "click");
	closebtn:setLabel("Close", 13, 1);
	closebtn:setImageColor({100,200,255,200},{150,250,255,200},{150,250,255,200});
	closebtn:setMode(2,{x=4, y=4, width=12, height=12}, iw, ih);
	closebtn.onButtonClick = function (this)
		wnd:close(2, {x=10, y=495, width = 55, height = 15}, true);
	end
	background:add(nil, closebtn, 120, 40);
	
	wnd:showGui(false);
	wnd:enableGui(false);
	
	gm:add("wnd", wnd);
end

function love.load()
	title = love.graphics.getCaption();

	g = Girl.Graphics();
	g:createImageFromPath("normal","psimg/normal.png");
	g:createImageFromPath("click","psimg/click.png");
	g:createFontFromSize("font8",8);
	g:createFontFromSize("font10",10);
	g._setBackgroundColor({0,0,0});
	
	gm = Girl.GuiManager();
	
	ps_init();
	gui_init();
	wnd_init();
end

function love.update(dt)
	love.graphics.setCaption(title..' [FPS: '..love.timer.getFPS()..']')

	if psclick then
		ps:setPosition(love.mouse.getX(), love.mouse.getY());
		ps:start()
	end
	ps:update(dt);
	gm:update(dt);
end

function love.draw()
	love.graphics.setColorMode("modulate")
	love.graphics.setBlendMode("additive")
	g:drawParticleSystem("ps", 0, 0);
	love.graphics.setBlendMode("alpha")
	
	if show_info then
		g:setFont("font10");
		g._setColor({255,255,255})
		love.graphics.print(ps_script(), 520, 10);
	end
	
	gm:draw();
end

function love.mousepressed(x, y, button)
	if gm:mousepressed(x, y, button) then
		return;
	end
	psclick = true;
end

function love.mousereleased(x, y, button)
	gm:mousereleased(x, y, button)
	psclick = false;
end

function love.keypressed(key, unicode)
	gm:keypressed(key, unicode);
end

function love.keyreleased(key)
	gm:keyreleased(key);
end
